package com.micro.service.auth.server.model;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Collection;

/**
 * @author lvxiucai
 * @description
 * @date 2019/7/15
 */
@Data
@Entity
@Table(name = "user")
@Slf4j
public class User implements UserDetails {
    @Id
    @Column(name = "id")
    private Long id;
    private String username;
    private String password;
    private String headImg;
    private String mobile;

    public User(Long id, String username, String password,String headImg, String mobile) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.headImg = headImg;
        this.mobile = mobile;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return AuthorityUtils.createAuthorityList("ROLE_USER");
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }





}
